Skip to content

fix(fetch): preserve Request __sapiom metadata - #691

Open
Kewe63 wants to merge 1 commit into
sapiom:mainfrom
Kewe63:fix-690-fetch-request-metadata
Open

fix(fetch): preserve Request __sapiom metadata#691
Kewe63 wants to merge 1 commit into
sapiom:mainfrom
Kewe63:fix-690-fetch-request-metadata

Conversation

@Kewe63

@Kewe63 Kewe63 commented Aug 23, 2026

Copy link
Copy Markdown

Summary

Fixes #690

@sapiom/fetch documents per-request overrides by attaching __sapiom metadata directly to a Request, including { enabled: false } to bypass Sapiom for one request.

However, createFetch() cloned the input with new Request(input, init) before reading metadata. Native Request cloning does not preserve custom properties, so Request.__sapiom was lost.

This PR preserves the metadata before cloning and reattaches it to cloned requests so per-request overrides keep working.


Changes

  • Read __sapiom metadata from the original Request before cloning.
  • Reattach metadata to the cloned request.
  • Preserve metadata across later internal request clones.
  • Add a regression test for Request.__sapiom = { enabled: false }.

How to Test

corepack pnpm --filter @sapiom/fetch test
corepack pnpm --filter @sapiom/fetch lint
corepack pnpm --filter @sapiom/fetch typecheck
corepack pnpm --filter @sapiom/fetch build
git diff --check

Checklist

  • Tests pass — new regression test covers Request.__sapiom = { enabled: false }
  • Lint, typecheck, and build clean
  • Follows Conventional Commits
  • Changes scoped to this fix only

Risk & Impact

Low. The fix only affects how __sapiom metadata survives internal Request cloning — it reads and reattaches the metadata rather than changing any clone or fetch behavior. Requests without __sapiom metadata are unaffected.

Type: 🐛 Bug fix
Fixes: #690

@github-actions github-actions Bot added contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation size: small Review size is at most 100 changed lines area: integrations Changes to HTTP or framework integrations labels Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: integrations Changes to HTTP or framework integrations contribution: incomplete Required pull request information is incomplete or ambiguous contributor: external Pull request author does not have write, maintain, or admin access to sapiom-js needs-triage Awaiting maintainer review and classification review: manual External pull request requires maintainer review before automation size: small Review size is at most 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: @sapiom/fetch loses Request.__sapiom metadata when cloning input

1 participant